package icu.sehnen.controller;


import icu.sehnen.common.CommonResult;
import icu.sehnen.model.NavModel;
import icu.sehnen.model.ProgressModel;
import icu.sehnen.service.ProgressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/progress")
public class ProgressController {
        @Autowired
        ProgressService progressService;
        @GetMapping("/list")
        public CommonResult findAll(){
            List<ProgressModel> progressModelList=progressService.findAll();
            return  CommonResult.success(progressModelList);
        }
        @GetMapping("/find/{id}")
        public  CommonResult findProgressById(@PathVariable Long id){
            ProgressModel progressModel=progressService.findProgressById(id);
            return  CommonResult.success(progressModel);
        }
        @PutMapping("/put")
        public CommonResult update(ProgressModel progressModel){
        progressService.update(progressModel);
            return  CommonResult.success();
        }
          @PostMapping("/add")
             public CommonResult add(ProgressModel progressModel){
        progressService.add(progressModel);
        return  CommonResult.success();
    }
        @DeleteMapping("/delete/{id}")
        public  CommonResult delete(@PathVariable Long id){
            progressService.delete(id);
            return  CommonResult.success();

    }
    @PutMapping("/delete/img")
    public  CommonResult deleteImg( Long id,String imgUrl){
        progressService.deleteImg(id,imgUrl);
        return  CommonResult.success();

    }
}
